Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
DiscordAPIError: Invalid Form Body 2.options[2].choices: Choices cannot be configured for this type of option

So I had just finished coding the ban command, and when I wanted to run the bot, I got a giant error. I never even had an idea what this error means, so if you could explain it to me while looking for the fix would be appreciated. If you can't, that's also okay.

DiscordAPIError: Invalid Form Body
2.options[2].choices: Choices cannot be configured for this type of option

I looked for the issue, but I can't seem to find any. Can someone help me with this one?

Here is the code:

const { Client, CommandInteraction, MessageEmbed } = require('discord.js');

module.exports = {
    name: 'ban',
    description: 'Bans the target member',
    permission: 'ADMINISTRATOR',
    options: [{
            name: 'target',
            description: 'Select a target to ban.',
            type: 'USER',
            required: true,
        },
        {
            name: 'reason',
            description: 'Provide a reason for this ban.',
            type: 'STRING',
            required: true,
        },
        {
            name: 'messages',
            description: 'Choose one of the choices.',
            type: 'USER',
            required: true,
            choices: [{
                    name: 'Don\'t delete any',
                    value: '0'
                },
                {
                    name: 'Previous 7 days.',
                    value: '7'
                }
            ]
        },
    ],
    /**
     * 
     * @param {Client} client 
     * @param {CommandInteraction} interaction 
     */
    async execute(client, interaction) {
        const { options, member } = interaction;

        const Target = options.getMember('target');

        if (Target.id === member.id)
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | You can't ban yourself.`)]
            })

        if (Target.permissions.has('ADMINISTRATOR'))
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | You can't an administrator.`)]
            })

        const Reason = options.getString('reason');

        if (Reason.length > 512)
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | The reason can't exceed 512 characters.`)]
            })

        const Amount = options.getString('messages')

        Target.ban({
            days: Amount,
            reason: Reason
        })

        interaction.reply({
            embeds: [new MessageEmbed().setColor('GREEN').setDescription(`✅ | **${target.user.username}** has been banned from the server.`)]
        })
    }
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The USER type can't have choices. It looks like you need STRING instead. For example, your code would look like this:

const { Client, CommandInteraction, MessageEmbed } = require('discord.js');

module.exports = {
    name: 'ban',
    description: 'Bans the target member',
    permission: 'ADMINISTRATOR',
    options: [{
            name: 'target',
            description: 'Select a target to ban.',
            type: 'USER',
            required: true,
        },
        {
            name: 'reason',
            description: 'Provide a reason for this ban.',
            type: 'STRING',
            required: true,
        },
        {
            name: 'messages',
            description: 'Choose one of the choices.',
            type: 'STRING',
            required: true,
            choices: [{
                    name: 'Don\'t delete any',
                    value: '0'
                },
                {
                    name: 'Previous 7 days.',
                    value: '7'
                }
            ]
        },
    ],
    /**
     * 
     * @param {Client} client 
     * @param {CommandInteraction} interaction 
     */
    async execute(client, interaction) {
        const { options, member } = interaction;

        const Target = options.getMember('target');

        if (Target.id === member.id)
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | You can't ban yourself.`)]
            })

        if (Target.permissions.has('ADMINISTRATOR'))
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | You can't an administrator.`)]
            })

        const Reason = options.getString('reason');

        if (Reason.length > 512)
            return interaction.reply({
                embeds: [new MessageEmbed().setColor('RED').setDescription(`⛔ | The reason can't exceed 512 characters.`)]
            })

        const Amount = options.getString('messages')

        Target.ban({
            days: Amount,
            reason: Reason
        })

        interaction.reply({
            embeds: [new MessageEmbed().setColor('GREEN').setDescription(`✅ | **${target.user.username}** has been banned from the server.`)]
        })
    }
};

See here for the reference.

Hoped this helped!

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda